<script type="text/javascript" src="/js/wys.js"></script>
<!--<link href="http://habrahabr.ru/css/1293353867/all.css" rel="stylesheet" media="all" />-->
<!--<script type="text/javascript" src="http://habrahabr.ru/js/1293353867/mootools-1.2-core-yc.js"></script>-->

<style>
    .panel a{font-size: 12px;}
</style>


<form method="POST" action="addmessage">
    <input type="hidden" name="messageIdFromGet" value="<?= $this->messageIdFromGet ?>"/>

    <div class="createMessageContainer padd-5">
        <div>
            <div class="mainContent">
                <h1>Добавление публикации</h1>
				Заголовок | Title<br />
                <input class="title" type="text" name="inputTitle" maxlength="255" title="Добавить заголовок пубикации (Message:title)" value="<?= $this->editedMessage ? $this->editedMessage->getTitle() : "" ?>"/>    
				Тело<br />

                <div class="editor">
                    <div class="panel">
                        <select class="with-title" name="h" onchange="deewyg.insertTagFromDropBox(this);" tabindex="-1">
                            <option value="" class="title">Заголовки:</option>
                            <option value="h1">Заголовок H1</option>
                            <option value="h2">Подзаголовок H2</option>
                            <option value="h3">Подподзаголовок H3</option>
                        </select>
        
                        <select class="with-title" name="list" onchange="deewyg.insertList(this);" tabindex="-1">
                            <option value="" class="title">Списки:</option>
                            <option value="ul">ul li</option>
                            <option value="ol">ol li</option>
                        </select>
        
                       
        
                        <a style="margin-left: 10px;" 
                           title="жирный" 
                           onclick="return deewyg.insertTagWithText(this, 'b');" 
                           href="#" 
                           tabindex="-1">&lsaquo;b&rsaquo;</a>
           
                        <a title="курсив" 
                           onclick="return deewyg.insertTagWithText(this, 'i');" 
                           href="#" 
                           tabindex="-1">
                            &lsaquo;i&rsaquo;
                        </a>
            
                        <a title="подчёркнутый" 
                           onclick="return deewyg.insertTagWithText(this, 'u');" 
                           href="#" 
                           tabindex="-1">
                            &lsaquo;u&rsaquo;
                        </a>
        
                        <a title="зачёркнутый" 
                           onclick="return deewyg.insertTagWithText(this, 's');" 
                           href="#" 
                           tabindex="-1">
                            &lsaquo;s&rsaquo;
                        </a>
        
                        <a style="margin: auto 10px;" 
                           title="код" 
                           onclick="return deewyg.insertTagWithText(this, 'code');" 
                           href="#" 
                           tabindex="-1" 
                           class="txt">&lsaquo;code&rsaquo;</a>
           
                    <!--    <a title="хабраюзер" onclick="return deewyg.insertUser(this);" href="#" tabindex="-1"><img width="20" height="20" alt="хабраюзер" src="/i/panel/user.gif"/></a>-->
    
                        <a title="вставить ссылку" 
                           onclick="return deewyg.insertLink(this);" 
                           href="#" 
                           tabindex="-1">&lsaquo;a&rsaquo;</a>
           
                        <a title="вставить изображение" 
                           onclick="return deewyg.insertImage(this);" 
                           href="#" 
                           tabindex="-1">&lsaquo;img&rsaquo;</a>
           
<!--                        <a title="вставить видео" onclick="return deewyg.insertTagWithText(this, 'video');" href="#" tabindex="-1"><img width="20" height="20" alt="video" src="/i/panel/video.gif"/></a>-->
        
                        <a style="margin-left: 10px;" 
                           title="хабракат" 
                           onclick="return deewyg.insertHabracut(this);" 
                           href="#" 
                           tabindex="-1" 
                           class="txt">
                            &lsaquo;deecat&frasl;&rsaquo;
                        </a>
        
                    </div>
                    <div class="text-holder">
                        <textarea id="topic-message"
                                  style="width:624px; height: 300px;"
                                  name="inputText"
                                  onkeydown="return deewyg.insertTab(event, this);"
                                  onkeyup="return deewyg.insertTab(event, this);"
                                  validate="required habracutme"><?= $this->editedMessage ? $this->editedMessage->getText() : "" ?></textarea>
            
                    </div>
                </div>
    
    
    
    
    
    
    
                Description<br />
                <textarea style="height: 60px;"name="seoOptions" cols="76" rows="2" title="краткое описание статьи"><?= $this->editedMessage ? $this->editedMessage->getSeoOptions() : "" ?></textarea>
				Keywords<br />
                <textarea style="height: 30px;"name="keywords" cols="76" rows="2" title="ключевые слова"><?= $this->editedMessage ? $this->editedMessage->getKeywords() : "" ?></textarea>
            </div>
                
            <div class="additionally">
                <dd>
                <dt>
                    user's NickName:
                    <select name="userId">
                        <? if ($this->editedMessage): ?>
                            <? $uploaderId = $this->editedMessage->getUser()->getUserId(); ?>
                        <? endif; ?>
                            
                            
                        <? foreach ($this->allUsers as $user): ?>
                                
                            <? $userId = $user->getUserId() ?>
                                    
                            <option value="<?= $user->getUserId() ?>" 
                                    
                                    <? if (isset($uploaderId) && ($userId == $uploaderId)): ?>    
                                        selected="selected"
                                    <? endif; ?>>
                                        <?= $user->getNickName() ?>
                                                
                            </option>
                        <? endforeach; ?>
                    </select>
                        
                </dt>
                    
                <? if (!$this->editedMessage): ?>
                    <dt>
                        Куда сохранять:
                        <select name="parentId">
                            <option value="new" selected="selected">Новая</option>
                            <? foreach ($this->allMesseges as $message): ?>
                                <option value="<?= $message->getMessageId() ?>">[<?= $message->getMessageId() ?>]: <?= $message->getType()->getTitle() ?>: <?= $message->getTitle() ?></option>
                            <? endforeach; ?>
                        </select>
                    </dt>
                <? endif; ?>
                    
                <dt>
                    Тип публикации:
                    <select name="publicationTypeId">
                        <? if ($this->editedMessage): ?>
                            <? $typeId = $this->editedMessage->getType()->getTypeId() ?>
                        <? endif; ?>
                            
                        <? foreach ($this->allMessegetTypes as $messageType): ?>
                            <? $messageTypeId = $messageType->getTypeId() ?>
                            <option value="<?= $messageType->getTypeId() ?>"
                            <? if (isset($typeId) && $typeId == $messageTypeId): ?>
                                        selected="selected"    
                                    <? endif; ?>>
                                        <?= $messageType->getTitle() ?>
                            </option>
                        <? endforeach; ?>
                    </select>
                        
                </dt>
                <dt>
                    createdAt
                    <input type="text" name="createdAt" disabled value="<?= $this->editedMessage ? $this->DateFormat($this->editedMessage->getCreatedAt()) : $this->globalNowDateTimeString ?>"/>
                </dt>
                <dt>
                    updatedAt
                    <input type="text" name="updatedAt" value="<?= $this->globalNowDateTimeString ?>"/>
                </dt>
                <dt>
                    <input type="submit" name="submitPublicate" value="<?= $this->editedMessage ? 'Сохранить' : 'Опубликовать' ?>"/>
                    <input type="submit" name="submitSaveInDrafts" value="В черновики"/>
                </dt>
                </dd>
                <? if ($this->editedMessage): ?>
                    <div class="editedMessageInfo">
                            
                            
                            
                        <? if ($this->editedMessage->getParentId() == $this->editedMessage->getMessageId()): ?>
                            Это сообщение является родителем. 
                            <? if (count($this->childsMessages) > 0): ?>
                                Его потомки:
                                <dd>
                                    <? foreach ($this->childsMessages as $child): ?>
                                    <dt>
                                        <a href="./addmessage/<?= $child->getMessageId() ?>">
                                            <?= $child->getTitle() ?>
                                        </a>
                                    </dt>
                                <? endforeach; ?>
                                </dd>
                            <? else: ?>
                                Потомков не имеется.
                            <? endif; ?>
                        <? endif; ?>
                                
                    </div>
                <? endif; ?>
                    
            </div>
                
                
        </div>    
            
    </div>
</form>